package com.hyt.it.ogt.kq.common.gov.enums.admission;

import com.hyt.it.ogt.kq.common.gov.constant.admission.AdmissionTicketTemplateCode;

import java.util.Arrays;
import java.util.Objects;

/**
 * 准考证无考场变量
 *
 * @author zhoumiao
 * @since 2023/2/7 15:56
 **/
public enum NotRoomCustomTemplateConfigEnum {
    NONE(null, "未知", 0),
    EXAM_NAME(AdmissionTicketTemplateCode.EXAM_NAME, "考试名称", 1),
    EXAM_START(AdmissionTicketTemplateCode.EXAM_START, "考试开始时间", 2),
    EXAM_END(AdmissionTicketTemplateCode.EXAM_END, "考试结束时间", 3),
    EXAM_URL(AdmissionTicketTemplateCode.EXAM_URL, "考试地址", 4),
    EXAM_ID(AdmissionTicketTemplateCode.EXAM_ID, "考试id", 5),
    EXAM_TIME(AdmissionTicketTemplateCode.EXAM_TIME, "考试时间", 6),
    ADMISSION_NO(AdmissionTicketTemplateCode.ADMISSION_NO, "准考证号", 7),
    ;
    private String code;
    private String text;
    private Integer sort;

    NotRoomCustomTemplateConfigEnum(String code, String text, int sort) {
        this.code = code;
        this.text = text;
        this.sort = sort;
    }

    public String getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public Integer getSort() {
        return sort;
    }

    /**
     * 是否公共信息
     *
     * @param code
     * @return
     */
    public static boolean isKwPublicInfo(String code) {
        return Arrays.stream(values()).anyMatch(admissionVirtualInfoEnum -> Objects.equals(code, admissionVirtualInfoEnum.code));
    }

    public static NotRoomCustomTemplateConfigEnum get(String code) {
        return Arrays.stream(values()).filter(admissionVirtualInfoEnum -> Objects.equals(code, admissionVirtualInfoEnum.code))
                .findFirst()
                .orElse(NotRoomCustomTemplateConfigEnum.NONE);
    }

}
